#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDebug>
#include <QTimer>
#include <QThread>
#include "mythread.h"
#include <QWebSocket>
#include <QtPrintSupport/QPrinter>
#include <QtPrintSupport/QPrintDialog>
#include <QtPrintSupport/QPrintPreviewDialog>
#include <QFileDialog>
#include <QFileInfo>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
#include <QXmlStreamReader>
#include <QStandardItemModel>
#include "printhandler.h"
#include "login.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void dealLogin(QString username, QString password);
    void dealTimeout();
    void mtRun();
    void updLable();

    void onDisconnected();
    void onConnected();
    void onTextReceived(QString msg);
    void reconnect();

    //打印
    void doPrint();
    //打印预览
    void doPrintPreview();
    void printPreview(QPrinter *printer);
    //生成pdf
    void createPdf();

    void exitLogin();
private:
    Ui::MainWindow *ui;
    QTimer *timer;
    QTimer *qsTimer;  
    MyThread *myThread;
    QThread *qThread;

    QWebSocket *qwebSocket;
    QIcon icon;

    Login *login;
    PrintHandler *handler;
    QWebEngineView *view;
protected:

signals:   
    void startThread();

private slots:
    void on_btn_qdxc_clicked();
    void on_btn_send_clicked();
    void on_btn_ws_select_clicked();
    void on_btn_dp_clicked();
    void on_btn_dpyl_clicked();
    void on_menu_quit_triggered();
    void on_pushButton_clicked();
};

#endif // MAINWINDOW_H
